import {useModel} from "@@/plugin-model/useModel";
import {useCallback, useMemo} from "react";


export default () => {
  const {initialState,} = useModel('@@initialState');
  const authorizes = useMemo(() => {
    return initialState?.currentUser?.authorities?.map(item => item.authority);
  }, [initialState?.currentUser]);
  const hasAuth = useCallback((authorize: string) => {
    return authorizes?.includes(authorize)
  }, [authorizes])
  const ret: [typeof authorizes, typeof hasAuth] = [authorizes, hasAuth];
  return ret;
}
